package com.example.homework3;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

public class MuchChoiceDialogFragment extends DialogFragment {
    private String[] genders = new String[]{"男", "女"};

    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
                .setTitle("多选对话框")
                .setMultiChoiceItems(genders, null, new DialogInterface.OnMultiChoiceClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                        if(isChecked){
//                            selectedItems.add(genders[which]);
                        }else {
//                            selectedItems.remove(genders[which]);
                        }
                    }
                });

        return builder.create();
    }
}
